package com.cxh.rmsq.utils.dialog

import android.content.Context
import android.content.Intent
import android.graphics.Bitmap
import android.text.SpannableString
import android.text.Spanned
import android.text.TextPaint
import android.text.method.LinkMovementMethod
import android.text.style.ClickableSpan
import android.text.style.ForegroundColorSpan
import android.view.View
import android.widget.ImageView
import android.widget.LinearLayout
import android.widget.TextView
import androidx.annotation.NonNull
import com.blankj.utilcode.util.ActivityUtils.startActivity
import com.cxh.rmsq.R
import com.cxh.rmsq.common.Constant
import com.cxh.rmsq.ui.activity.WebViewActivity
import com.cxh.rmsq.ui.widget.SelectableRoundedImageView
import com.cxh.rmsq.utils.LoadBitmapFromViewUtil
import com.cxh.rmsq.utils.MyUtils
import com.cxh.rmsq.utils.loadImage
import com.hjq.shape.layout.ShapeRelativeLayout
import com.hjq.shape.view.ShapeTextView
import com.lihang.ShadowLayout
import com.lxj.xpopup.core.BottomPopupView
import com.lxj.xpopup.core.CenterPopupView
import com.lxj.xpopup.util.XPopupUtils
import kotlin.math.roundToInt
import kotlin.system.exitProcess


class SharePopup(context: Context, avator: String, name: String, url: String, click: onClick) :
    BottomPopupView(context) {

    interface onClick {
        fun click(s: Int, s1: String)
    }

    var func: onClick
    var name: String
    var avator: String
    var url: String

    init {
        this.func = click
        this.url = url
        this.name = name
        this.avator = avator
    }

    override fun getImplLayoutId(): Int {
        return R.layout.share_popup
    }

    override fun onCreate() {
        super.onCreate()

        var ll_chat = findViewById<LinearLayout>(R.id.ll_chat)
        var ll_chat_circle = findViewById<LinearLayout>(R.id.ll_chat_circle)
        var ll_qq = findViewById<LinearLayout>(R.id.ll_qq)
        var ll_zone = findViewById<LinearLayout>(R.id.ll_zone)
        var ll_contact = findViewById<LinearLayout>(R.id.ll_contact)
        var ll_save = findViewById<LinearLayout>(R.id.ll_save)

        var tv_ok = findViewById<ShapeTextView>(R.id.tv_ok)

        ll_chat.setOnClickListener {
            func.click(1, "")
            dismiss()
        }
        ll_chat_circle.setOnClickListener {
            func.click(2, "")
            dismiss()
        }
        ll_qq.setOnClickListener {
            func.click(3, "")
            dismiss()
        }
        ll_zone.setOnClickListener {
            func.click(4, "")
            dismiss()
        }
        ll_contact.setOnClickListener {
            func.click(5, "")
            dismiss()
        }
        ll_save.setOnClickListener {
            func.click(6, "")
            dismiss()
        }

        tv_ok.setOnClickListener {
            dismiss()
        }
    }

    // 最大高度为Window的0.85
    override fun getMaxHeight(): Int {
        return ((XPopupUtils.getAppHeight(context) * 1f).roundToInt())
    }

}